package org.Set.HashSet;

import java.util.HashSet;
import java.util.Iterator;

/**
 * @author rain-falling-cold-s
 **/
public class HashSetDemo {
    public static void main(String[] args) {
        HashSet<String> words = new HashSet<String>();
        words.add("one");
        words.add("two");
        words.add("three");
        //哈希散列不能添加重复的元素
        words.add("one");
        Iterator<String> hashSet = words.iterator();
        try {
            for (; hashSet.hasNext(); ) {
                System.out.println(hashSet.next());
            }
        } catch (Exception e) {
            e.printStackTrace(System.out);
        } finally {
            for (var word : words) {
                System.out.print(word + " ");
            }
        }
    }
}
